package com.ruoyi.cms.domain;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;

/**
 * 数据模型字段对象 cms_model_field
 * 
 * @author ruoyi
 * @date 2021-07-29
 */
public class CmsModelField extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 字段ID */
    private Long fieldId;

    /** 模型ID */
    @Excel(name = "模型ID")
    private Long modelId;

    /** 字段编码 */
    @Excel(name = "字段编码")
    private String fieldCode;

    /** 字段名称 */
    @Excel(name = "字段名称")
    private String fieldName;

    /** 字段类别 */
    @Excel(name = "字段类别")
    private String fieldType;

    /** 字段长度 */
    @Excel(name = "字段长度")
    private Integer fieldLength;

    /** 表单类别 */
    @Excel(name = "表单类别")
    private String formType;

    /** 非空标识（Y是 N否） */
    @Excel(name = "非空标识", readConverterExp = "Y=是,N=否")
    private String reqFlag;

    /** 字段排序 */
    @Excel(name = "字段排序")
    private Integer ord;

    public void setFieldId(Long fieldId) 
    {
        this.fieldId = fieldId;
    }

    public Long getFieldId() 
    {
        return fieldId;
    }
    public void setModelId(Long modelId) 
    {
        this.modelId = modelId;
    }

    public Long getModelId() 
    {
        return modelId;
    }
    public void setFieldCode(String fieldCode) 
    {
        this.fieldCode = fieldCode;
    }

    public String getFieldCode() 
    {
        return fieldCode;
    }
    public void setFieldName(String fieldName) 
    {
        this.fieldName = fieldName;
    }

    public String getFieldName() 
    {
        return fieldName;
    }
    public void setFieldType(String fieldType) 
    {
        this.fieldType = fieldType;
    }

    public String getFieldType() 
    {
        return fieldType;
    }
    public void setFieldLength(Integer fieldLength) 
    {
        this.fieldLength = fieldLength;
    }

    public Integer getFieldLength() 
    {
        return fieldLength == null ? 0 : fieldLength;
    }
    public void setFormType(String formType) 
    {
        this.formType = formType;
    }

    public String getFormType() 
    {
        return formType;
    }
    public void setReqFlag(String reqFlag) 
    {
        this.reqFlag = reqFlag;
    }

    public String getReqFlag() 
    {
        return reqFlag;
    }
    public void setOrd(Integer ord) 
    {
        this.ord = ord;
    }

    public Integer getOrd() 
    {
        return ord == null ? 0 : ord;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("fieldId", getFieldId())
            .append("modelId", getModelId())
            .append("fieldCode", getFieldCode())
            .append("fieldName", getFieldName())
            .append("fieldType", getFieldType())
            .append("fieldLength", getFieldLength())
            .append("formType", getFormType())
            .append("reqFlag", getReqFlag())
            .append("ord", getOrd())
            .toString();
    }

    public boolean isReq() {
        return "Y".equals(reqFlag);
    }

    public boolean isNumber() {
        return "INT".equals(fieldType) || "BIGINT".equals(fieldType) || "DECIMAL".equals(fieldType);
    }

    public boolean isVarchar() {
        return "VARCHAR".equals(fieldType);
    }

    public boolean isDecimal() {
        return "DECIMAL".equals(fieldType);
    }

    public boolean isText() {
        return "LONGTEXT".equals(fieldType);
    }

    public boolean isDate() {
        return "DATETIME".equals(fieldType);
    }

}
